<?php

/**
 * InsAbonnement filter form base class.
 *
 * @package    tfe
 * @subpackage filter
 * @author     3emeIG
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedInheritanceTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseInsAbonnementFormFilter extends InscriptionFormFilter
{
  protected function setupInheritance()
  {
    parent::setupInheritance();

    $this->widgetSchema   ['id_abonnement'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Abonnement'), 'add_empty' => true));
    $this->validatorSchema['id_abonnement'] = new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Abonnement'), 'column' => 'id'));

    $this->widgetSchema   ['jour_de_la_semaine'] = new sfWidgetFormChoice(array('choices' => array('' => '', 'lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche')));
    $this->validatorSchema['jour_de_la_semaine'] = new sfValidatorChoice(array('required' => false, 'choices' => array('lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche')));

    $this->widgetSchema   ['parrain'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Parrain'), 'add_empty' => true));
    $this->validatorSchema['parrain'] = new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Parrain'), 'column' => 'id'));

    $this->widgetSchema   ['cadeau_recu'] = new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')));
    $this->validatorSchema['cadeau_recu'] = new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0)));

    $this->widgetSchema   ['paiement_en_deux_fois'] = new sfWidgetFormChoice(array('choices' => array('' => '', 'non' => 'non', 'oui' => 'oui')));
    $this->validatorSchema['paiement_en_deux_fois'] = new sfValidatorChoice(array('required' => false, 'choices' => array('non' => 'non', 'oui' => 'oui')));

    $this->widgetSchema   ['mode_de_paiement_second_semestre'] = new sfWidgetFormChoice(array('choices' => array('' => '', 'liquide' => 'liquide', 'virement' => 'virement', 'carte' => 'carte', 'chèque' => 'chèque')));
    $this->validatorSchema['mode_de_paiement_second_semestre'] = new sfValidatorChoice(array('required' => false, 'choices' => array('' => '', 'liquide' => 'liquide', 'virement' => 'virement', 'carte' => 'carte', 'chèque' => 'chèque')));

    $this->widgetSchema   ['date_de_paiement_second_semestre'] = new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate()));
    $this->validatorSchema['date_de_paiement_second_semestre'] = new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false))));

    $this->widgetSchema   ['code_de_paiement_second_semestre'] = new sfWidgetFormFilterInput();
    $this->validatorSchema['code_de_paiement_second_semestre'] = new sfValidatorPass(array('required' => false));

    $this->widgetSchema   ['a_envoyer'] = new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')));
    $this->validatorSchema['a_envoyer'] = new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0)));

    $this->widgetSchema   ['envoyee'] = new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no')));
    $this->validatorSchema['envoyee'] = new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0)));

    $this->widgetSchema   ['liste_des_representations_list'] = new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'RepresentationSpectacle'));
    $this->validatorSchema['liste_des_representations_list'] = new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'RepresentationSpectacle', 'required' => false));

    $this->widgetSchema->setNameFormat('ins_abonnement_filters[%s]');
  }

  public function addListeDesRepresentationsListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query->leftJoin('r.ListeRepresentations ListeRepresentations')
          ->andWhereIn('ListeRepresentations.id_evenement', $values);
  }

  public function getModelName()
  {
    return 'InsAbonnement';
  }

  public function getFields()
  {
    return array_merge(parent::getFields(), array(
      'id_abonnement' => 'ForeignKey',
      'jour_de_la_semaine' => 'Enum',
      'parrain' => 'ForeignKey',
      'cadeau_recu' => 'Boolean',
      'paiement_en_deux_fois' => 'Enum',
      'mode_de_paiement_second_semestre' => 'Enum',
      'date_de_paiement_second_semestre' => 'Date',
      'code_de_paiement_second_semestre' => 'Text',
      'a_envoyer' => 'Boolean',
      'envoyee' => 'Boolean',
      'liste_des_representations_list' => 'ManyKey',
    ));
  }
}
